package com.deyuanyun.pic.ctrl.controller.dto;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.poi.annotation.ExcelWriteColumn;
import com.deyuanyun.pic.ctrl.enumeration.InfluencePositionEnum;
import com.deyuanyun.pic.ctrl.mapper.EqptCptestStationMapper;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Description 交流电气化铁路系统干扰源DTO
 * @author Jerry
 * @date 2016-09-07
 */
public class InfluenceAcerDTO {
    /**
     * 主键
     */
    private String id;

    /**
     * 创建时间
     */
    private Date createDate;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建备注
     */
    private String createRemark;

    /**
     * 更新时间
     */
    private Date updateDate;

    /**
     * 更新人员
     */
    private String updateUser;

    /**
     * 更新原因
     */
    private String updateRemark;

    /**
     * 逻辑删除字段
     */
    private Short deleted;

    /**
     * 版本
     */
    private Short version;

    /**
     * 是否是最新数据，0：最新数据；1：历史数据
     */
    private Short isNewest;

    /**
     * 数据状态
     */
    private String dataStated;

    /**
     * 所属管道Id
     */
    private String pipeLineId;

    /**
     * 所属管道
     */
    @ExcelWriteColumn
    private String pipeName;

    /**
     * 统一编号
     */
    private String code;

    /**
     * 设备编号(自定义编号)
     */
    @ExcelWriteColumn
    private String customNumber;

    /**
     * 干扰源名称
     */
    @ExcelWriteColumn
    private String name;

    /**
     * 相对位置关系(平行、交叉)
     */
    @ExcelWriteColumn
    private String relativePositionRelation;


    /**
     * 平行段起点GISID
     */
    private String gisid;

    /**
     * 平行段起点_绝对里程
     */
    @ExcelWriteColumn
    private String beginMileage;

    /**
     * 平行起点_附近测试桩
     */

    private String beginNagm;
    @ExcelWriteColumn
    private String pbeginNgm;

    /**
     * 平行起点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String beginNagmMileage;

    /**
     * 平行段终点_绝对里程
     */
    @ExcelWriteColumn
    private String endMileage;

    /**
     * 平行段终点_附近测试桩
     */

    private String endNagm;
    @ExcelWriteColumn
    private String pendNgm;

    /**
     * 平行段终点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String endNagmMileage;

    /**
     * 最小平行间距
     （m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistance;

    /**
     * 平行距离（由系统计算，终点距离-起点距离）
     */
     @ExcelWriteColumn
      private BigDecimal parallelMileage;

    /**
     * 交叉段_绝对里程
     */
    @ExcelWriteColumn
    private String crossMileage;

    /**
     * 交叉段_附近测试桩
     */

    private String crossNagm;
    @ExcelWriteColumn
    private String crossNgm;



    /**
     * 交叉段_附近测试桩距离
     */
    @ExcelWriteColumn
    private String crossNagmMileage;

    /**
     * 位置描述
     */
    @ExcelWriteColumn
    private String locationDescription;

    /**
     * 接地体与管道最小距离（m）
     */
    @ExcelWriteColumn
    private BigDecimal groundMinDistance;

    /**
     * 牵引变电所_X
     */
    private BigDecimal substationX;

    /**
     * 牵引变电所_Y
     */
    private BigDecimal substationY;

    /**
     * 牵引变电所_Z
     */
    private BigDecimal substationZ;

    /**
     * 牵引变电所_绝对里程
     */
    public Long substationMileage;

    /**
     * 牵引变电所_附近测试桩
     */
    private String substationNagm;

    /**
     * 牵引变电所_附近测试桩距离
     */
    private String substationNagmMileage;

    /**
     * 牵引变电所位置描述
     */
    @ExcelWriteColumn
    private String substationLocationDesc;

    /**
     * 距管道最小距离（m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistanceFromPipe;

    /**
     * 高压杆塔与管道最小距离（m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistanceTower;

    /**
     * 供电方式
     */
    @ExcelWriteColumn
    private String powerSupplyMode;

    /**
     * 供电臂_短时电流
     */
    @ExcelWriteColumn
    public Long shorTtimeCurrent;

    /**
     * 供电臂_有效电流
     */
    @ExcelWriteColumn
    public Long effectiveCurrent;

    /**
     * 运行情况记录
     */
    @ExcelWriteColumn
    private String runRecord;

    /**
     * 检测日期
     */
    @ExcelWriteColumn
    private Date testingDate;

    /**
     * 检测单位
     */
    @ExcelWriteColumn
    private String testingCompany;


    /**
     * 记录人（直接存名称）
     */
    @ExcelWriteColumn
    private String recorder;

    /**
     * 记录时间
     */
    @ExcelWriteColumn
    private Date recordTime;

    /**
     * 备注
     */
    @ExcelWriteColumn
    private String remarks;

    /**
     * 业务组织路径
     */
    private String orgBizPath;

    /**
     * 管道gisId
     */
    private String pipeGisId;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getCreateRemark() {
        return createRemark;
    }

    public void setCreateRemark(String createRemark) {
        this.createRemark = createRemark;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public String getUpdateRemark() {
        return updateRemark;
    }

    public void setUpdateRemark(String updateRemark) {
        this.updateRemark = updateRemark;
    }

    public Short getDeleted() {
        return deleted;
    }

    public void setDeleted(Short deleted) {
        this.deleted = deleted;
    }

    public Short getVersion() {
        return version;
    }

    public void setVersion(Short version) {
        this.version = version;
    }

    public Short getIsNewest() {
        return isNewest;
    }

    public void setIsNewest(Short isNewest) {
        this.isNewest = isNewest;
    }

    public String getDataStated() {
        return dataStated;
    }

    public void setDataStated(String dataStated) {
        this.dataStated = dataStated;
    }

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getPipeName() {
        return pipeName;
    }

    public void setPipeName(String pipeName) {
        this.pipeName = pipeName;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRelativePositionRelation() {
        if(InfluencePositionEnum.PARALLEL.toString().equals(this.relativePositionRelation)){
            return "平行";
        }else if(InfluencePositionEnum.ACROSS.toString().equals(this.relativePositionRelation)){
            return "交叉";
        }
        return null;
    }

    public void setRelativePositionRelation(String relativePositionRelation) {
        this.relativePositionRelation = relativePositionRelation;
    }

    public String getGisid() {
        return gisid;
    }

    public void setGisid(String gisid) {
        this.gisid = gisid;
    }

    public String getBeginMileage() {
        return transformNum(beginMileage);
    }

    public void setBeginMileage(String beginMileage) {
        this.beginMileage = beginMileage;
    }

    public String getBeginNagm() {

        return beginNagm;
    }

    public void setBeginNagm(String beginNagm) {
        this.beginNagm = beginNagm;
    }

    public String getBeginNagmMileage() {
        return transformNum(beginNagmMileage);
    }

    public void setBeginNagmMileage(String beginNagmMileage) {
        this.beginNagmMileage = beginNagmMileage;
    }

    public String getEndMileage() {
        return transformNum(endMileage);
    }

    public void setEndMileage(String endMileage) {
        this.endMileage = endMileage;
    }

    public String getEndNagm() {

        return endNagm;
    }

    public void setEndNagm(String endNagm) {
        this.endNagm = endNagm;
    }

    public String getEndNagmMileage() {
        return transformNum(endNagmMileage);
    }

    public void setEndNagmMileage(String endNagmMileage) {
        this.endNagmMileage = endNagmMileage;
    }

    public BigDecimal getMinDistance() {
        return minDistance;
    }

    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    public String getCrossMileage() {
        return transformNum(crossMileage);
    }

    public void setCrossMileage(String crossMileage) {
        this.crossMileage = crossMileage;
    }

    public String getCrossNagm() {

        return crossNagm;
    }

    public void setCrossNagm(String crossNagm) {
        this.crossNagm = crossNagm;
    }

    public String getCrossNagmMileage() {
        return transformNum(crossNagmMileage);
    }

    public void setCrossNagmMileage(String crossNagmMileage) {
        this.crossNagmMileage = crossNagmMileage;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public BigDecimal getGroundMinDistance() {
        return groundMinDistance;
    }

    public void setGroundMinDistance(BigDecimal groundMinDistance) {
        this.groundMinDistance = groundMinDistance;
    }

    public BigDecimal getSubstationX() {
        return substationX;
    }

    public void setSubstationX(BigDecimal substationX) {
        this.substationX = substationX;
    }

    public BigDecimal getSubstationY() {
        return substationY;
    }

    public void setSubstationY(BigDecimal substationY) {
        this.substationY = substationY;
    }

    public BigDecimal getSubstationZ() {
        return substationZ;
    }

    public void setSubstationZ(BigDecimal substationZ) {
        this.substationZ = substationZ;
    }

    public Long getSubstationMileage() {
        return substationMileage;
    }

    public void setSubstationMileage(Long substationMileage) {
        this.substationMileage = substationMileage;
    }

    public String getSubstationNagm() {
        return substationNagm;
    }

    public void setSubstationNagm(String substationNagm) {
        this.substationNagm = substationNagm;
    }

    public String getSubstationNagmMileage() {
        return substationNagmMileage;
    }

    public void setSubstationNagmMileage(String substationNagmMileage) {
        this.substationNagmMileage = substationNagmMileage;
    }

    public String getSubstationLocationDesc() {
        return substationLocationDesc;
    }

    public void setSubstationLocationDesc(String substationLocationDesc) {
        this.substationLocationDesc = substationLocationDesc;
    }

    public BigDecimal getMinDistanceFromPipe() {
        return minDistanceFromPipe;
    }

    public void setMinDistanceFromPipe(BigDecimal minDistanceFromPipe) {
        this.minDistanceFromPipe = minDistanceFromPipe;
    }

    public BigDecimal getMinDistanceTower() {
        return minDistanceTower;
    }

    public void setMinDistanceTower(BigDecimal minDistanceTower) {
        this.minDistanceTower = minDistanceTower;
    }

    public String getPowerSupplyMode() {
        return powerSupplyMode;
    }

    public void setPowerSupplyMode(String powerSupplyMode) {
        this.powerSupplyMode = powerSupplyMode;
    }

    public Long getShorTtimeCurrent() {
        return shorTtimeCurrent;
    }

    public void setShorTtimeCurrent(Long shorTtimeCurrent) {
        this.shorTtimeCurrent = shorTtimeCurrent;
    }

    public Long getEffectiveCurrent() {
        return effectiveCurrent;
    }

    public void setEffectiveCurrent(Long effectiveCurrent) {
        this.effectiveCurrent = effectiveCurrent;
    }

    public String getRunRecord() {
        return runRecord;
    }

    public void setRunRecord(String runRecord) {
        this.runRecord = runRecord;
    }

    public Date getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(Date testingDate) {
        this.testingDate = testingDate;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getRecorder() {
        return recorder;
    }

    public void setRecorder(String recorder) {
        this.recorder = recorder;
    }

    public Date getRecordTime() {
       // return recordTime = new Date();
        return recordTime;
    }

    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getOrgBizPath() {
        return orgBizPath;
    }

    public void setOrgBizPath(String orgBizPath) {
        this.orgBizPath = orgBizPath;
    }

    public String getPipeGisId() {
        return pipeGisId;
    }

    public void setPipeGisId(String pipeGisId) {
        this.pipeGisId = pipeGisId;
    }

    public BigDecimal getParallelMileage() {
     if(this.beginMileage != null && this.endMileage !=null){
         return parallelMileage =new BigDecimal(Long.parseLong(this.endMileage)-Long.parseLong(this.beginMileage)).
                 divide(new BigDecimal(1000)).setScale(3,BigDecimal.ROUND_DOWN) ;
     }else{
         return null;
     }
    }

    public void setParallelMileage(BigDecimal parallelMileage) {
        this.parallelMileage = parallelMileage;
    }

    public String getPbeginNgm() {
        return pbeginNgm;
    }

    public void setPbeginNgm(String pbeginNgm) {
        this.pbeginNgm = pbeginNgm;
    }

    public String getPendNgm() {
        return pendNgm;
    }

    public void setPendNgm(String pendNgm) {
        this.pendNgm = pendNgm;
    }

    public String getCrossNgm() {
        return crossNgm;
    }

    public void setCrossNgm(String crossNgm) {
        this.crossNgm = crossNgm;
    }

    /**
     * 用string处理数据保持精度的正确（转化为3位小数）
     * @param mileage
     * @return
     */
    private  String transformNum(String mileage){
              if(mileage!=null){
                  return new BigDecimal(mileage).divide(new BigDecimal(1000)).setScale(3,BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString();
              }else{
                  return null;
              }
    }




}
